package com.vates.login.dao.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import com.vates.login.util.LoginConstants;

@Component
@Aspect
public class LogInterceptor {
		
	private final Logger LOGGER = Logger.getLogger(LogInterceptor.class);
	

	@Around("execution(* com.vates.login.dao.impl.*.*(..))")
	public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
		String className = joinPoint.getTarget().getClass().getName();
		String fullMethodName = className + LoginConstants.DOT + joinPoint.getSignature().getName();
		
		LOGGER.info(LoginConstants.LOG_START_METHOD + fullMethodName);
		
		Object result = joinPoint.proceed();
		
		LOGGER.info(LoginConstants.LOG_FINISH_METHOD + fullMethodName);
		
		return result;
	}
}
